/*
 * @Author: zwf 240970521@qq.com
 * @Date: 2023-08-05 00:42:54
 * @LastEditors: zwf 240970521@qq.com
 * @LastEditTime: 2023-08-06 02:39:40
 * @FilePath: /esp32_motor/motor/inc/smbObserver.h
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#ifndef SMB_OBSERVER_H
#define SMB_OBSERVER_H

#include "math_common.h"

typedef struct
{
    double  Valpha;     //二相静止坐标系alpha-轴电压
    double  Ealpha;     //二相静止坐标系alpha-轴反电动势
    double  Zalpha;     //alfa轴滑膜观测器的z平面
    double  EstIalpha;  //滑膜估算alpha-轴电流
    double  Vbeta;      //二相静止坐标系beta-轴电压
    double  Ebeta;      //二相静止坐标系beta-轴反电动势
    double  Zbeta;      //beta轴滑膜观测器的z平面
    double  EstIbeta;   //滑膜估算beta-轴电流
    double  Ialpha;     //二相静止坐标系alpha-轴电流
    double  IalphaError;//二相静止坐标系beta-轴电流误差
    double  Kslide;     //滤波器系数
    double  Ibeta;      //二相静止坐标系beta-轴电流
    double  IbetaError; //二相静止坐标系beta-轴电流误差
    double  Kslf;       //滤波器系数
    double  E0;         //滑膜的电流误差的限幅值 0.5
    double  Fsmopos;    // 滑膜系数1
    double  Gsmopos;    // 滑膜系数2
    double  pllKi;
    double  pllKp;
    double  pllErr;
    double  pllInterg;
    double  pllUi;
    int16_t qAngle;
    int16_t qPllAngle;
} AngleSMO;

typedef struct
{
    double Rs;     //电机的相电阻
    double Ls;     //电机的相电感
    double Ib;     //电机控制器的基本相电流
    double Vb;     //电机控制器的基本相电压
    double Ts;     //采样周期
    double Fsmopos;//滑膜常数1
    double Gsmopos;//滑膜常数2

} SmbObserverObj;

extern AngleSMO smbAngle;

/*函数*/
void SMO_observerInit(void);
void SMO_currCale(void);

#endif
